Skip to content

refactor(bigframes): Simplify @udf wrapper object#16556

Open
TrevorBergeron wants to merge 5 commits intomainfrom
tbergeron_udf_return_change
Open

refactor(bigframes): Simplify @udf wrapper object#16556
TrevorBergeron wants to merge 5 commits intomainfrom
tbergeron_udf_return_change

Conversation

@TrevorBergeron
Copy link
Copy Markdown
Contributor

Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly:

  • Make sure to open an issue as a bug/issue before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea
  • Ensure the tests and linter pass
  • Code coverage does not decrease (if any source code was changed)
  • Appropriate docs were updated (if necessary)

Fixes #<issue_number_goes_here> 🦕

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the User Defined Function (UDF) infrastructure by introducing a Udf protocol and a UdfRoutine dataclass, effectively consolidating the handling of BigQuery routines and removing the BigqueryCallableRowRoutine class. Code throughout the library now utilizes isinstance(..., Udf) for type checking. Furthermore, the system tests for managed functions have been significantly updated to use a pytest fixture for more reliable resource cleanup. Feedback was provided regarding the incorrect use of @functools.partial as a decorator on the UdfRoutine.__call__ method, which should be removed.

Comment thread packages/bigframes/bigframes/functions/function.py Outdated
@TrevorBergeron TrevorBergeron marked this pull request as ready for review April 14, 2026 20:42
@TrevorBergeron TrevorBergeron requested review from a team as code owners April 14, 2026 20:42
@TrevorBergeron TrevorBergeron requested review from tswast and removed request for a team April 14, 2026 20:42
Comment thread packages/bigframes/bigframes/functions/_function_session.py
Comment thread packages/bigframes/bigframes/functions/_function_session.py
Comment thread packages/bigframes/bigframes/functions/function.py
Comment thread packages/bigframes/bigframes/functions/function.py
if callable(condition):
# When it's a bigframes function.
if hasattr(condition, "bigframes_bigquery_function"):
if isinstance(condition, bigframes.functions.Udf):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I presume this is the reason for runtime_checkable above?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exactly

@TrevorBergeron TrevorBergeron requested a review from tswast April 15, 2026 17:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants